package com.xiguaji.tiktok.v1.ins.brand.repository;

import com.xiguaji.tiktok.v1.ins.brand.model.BrandGenderResp;
import com.xiguaji.tiktok.v1.ins.brand.model.InsStBrandGender;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

public interface InsStBrandGenderRepository extends CrudRepository<InsStBrandGender,Integer> {

    @Query("select gd.female_rate,(1 - gd.female_rate) male_rate,gd.adult_rate,gr.generation age,gr.generation_rate age_rate from ins_st_brand_gender gd left join " +
            "ins_st_brand_generation gr on gd.bid = gr.bid and gr.generation_rank = 1 where gd.bid = :bid")
    BrandGenderResp findByBid(int bid);
}
